{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "### List of files to analyze. You can use the wildcard to gather files in one directory for one run. \n",
    "filepaths = [\"../../datasets/G1GC.log\", \n",
    "             \"../../datasets/ShenandoahGC.log\",\n",
    "             \"../../datasets/ZGC.*\"] # uses wild card to capture both ZGC.log.0 and ZGC.log.1 files\n",
    "\n",
    "### Describe the files above. Each index in the list corresponds to one GC log run.   \n",
    "labels = [\"G1GC\",\n",
    "          \"ShenandoahGC\",\n",
    "          \"ZGC\"]\n",
    "\n",
    "# Used for development. Changes made in other files are reflected here.\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "\n",
    "# Import all required packages onto local computer\n",
    "import sys\n",
    "!{sys.executable} -m pip install matplotlib -q # plotting \n",
    "!{sys.executable} -m pip install pandas -q # store gc event data\n",
    "!{sys.executable} -m pip install numpy -q # computations on gc event data\n",
    "\n",
    "files = []\n",
    "import sys\n",
    "import os.path\n",
    "sys.path.append(\"../../\")\n",
    "sys.path.append(\"../\")     \n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "plt.rcParams[\"figure.figsize\"] = [12, 7] #  Size of figures created from plots by default [12,7]\n",
    "from src.read_log_file import get_gc_event_tables, get_file_names_wildcard, zero_start_times\n",
    "# Get all files\n",
    "for filepath in filepaths:\n",
    "    files.append(get_file_names_wildcard(filepath))\n",
    "\n",
    "# Parse all files\n",
    "gc_event_dataframes = get_gc_event_tables(files, None)\n",
    "\n",
    "# Check that there are the correct number of labels.\n",
    "if len(gc_event_dataframes) != len(labels):\n",
    "    print(\"Error: Labels do not have same length as collected data\")\n",
    "\n"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "\n",
    "\n",
    "from src.graphing.plotting import plot_scatter_universal \n",
    "\n",
    "def get_percent(data):\n",
    "    maxd = max(data)\n",
    "    return maxd / (8 * 1024)\n",
    "\n",
    "def get_percentage_f(flo):\n",
    "\n",
    "    return flo / (8 * 1024) * 100\n",
    "\n",
    "def filter_heap_after_gc(row):\n",
    "    if \"HeapAfterGC\" in row:\n",
    "        if row[\"HeapAfterGC\"] != None:\n",
    "            return True\n",
    "    return False\n",
    "plot = plot_scatter_universal(gc_event_dataframes, \n",
    "                            group_by = None, \n",
    "                            filter_by = filter_heap_after_gc,\n",
    "                            labels = labels,\n",
    "                            colors = None,\n",
    "                            plot = None,\n",
    "                            column = \"HeapAfterGC\",\n",
    "                            column_timing = \"TimeFromStart_seconds\",\n",
    "                            interval_duration = None,\n",
    "                            grouping_function = get_percentage_f,\n",
    "                            include_timing_in_bucket = False,\n",
    "                            line_graph= False )"
   ],
   "outputs": [
    {
     "output_type": "error",
     "ename": "NameError",
     "evalue": "name 'heap_before_gc' is not defined",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m/var/folders/n6/950_vq0d7hg9fc_04_5pxr0w0000gn/T/ipykernel_15307/1396078236.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     11\u001b[0m plot = plot_scatter_universal(gc_event_dataframes, \n\u001b[1;32m     12\u001b[0m                             \u001b[0mgroup_by\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 13\u001b[0;31m                             \u001b[0mfilter_by\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mheap_before_gc\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     14\u001b[0m                             \u001b[0mlabels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlabels\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     15\u001b[0m                             \u001b[0mcolors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'heap_before_gc' is not defined"
     ]
    }
   ],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.9.6",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.9.6 64-bit"
  },
  "interpreter": {
   "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}